#set(title="会员登录")
#@WeuiLayout()
#define cssStyle()
<style>
	#authBox {height: 100%;background-image: url('#(res_path)/image/member_login_bg.jpg');color: #F3F3F3}
	#authBox .iconfont {color: #999;font-size: 21px}
	#authBox .weui-cells_form {margin: 0 15px;border-radius:5px;}
	#authBox .weui-cells_form .weui-cell__hd {width: 30px}
	#authBox .weui-cells_form .weui-input {font-size: 14px;color: #333}
	#authBox .weui-msg__opr-area {padding: 5px 0px}
	#authBox .weui-msg__opr-area .weui-btn {margin-bottom: 20px}
</style>
#end
#define content()
<div id="authBox">
	<form onsubmit="return ajaxSubmit(this)">
		<div class="weui-msg" style="max-width: 350px;margin: 0 auto;">
		  <div class="weui-msg__text-area">
		    <h2 class="weui-msg__title">#(param("AUTH_MEMBER_NAME"))</h2>
		    <p class="weui-msg__desc">请按提示输入以下内容</a></p>
		  </div>
			<div class="weui-cells weui-cells_form">
			  <div class="weui-cell">
			    <div class="weui-cell__hd"><i class="iconfont icon-yonghuming"></i></div>
			    <div class="weui-cell__bd">
			      <input class="weui-input" type="text" name="username" placeholder="用户名/手机号/邮箱">
			    </div>
			  </div>
			  <div class="weui-cell">
			    <div class="weui-cell__hd"><i class="iconfont icon-mima"></i></div>
			    <div class="weui-cell__bd">
			      <input class="weui-input" type="password" name="password" placeholder="请输入登录密码">
			    </div>
			  </div>
				<div class="weui-cell weui-cell_vcode" style="display: none;">
        	<div class="weui-cell__hd"><i class="iconfont icon-yanzhengma"></i></div>
        	<div class="weui-cell__bd">
          	<input class="weui-input" placeholder="请输入验证码" type="text" name="captcha">
        	</div>
        	<div class="weui-cell__ft"><img class="weui-vcode-img" src="captcha"></div>
      	</div>
			</div>
		  <div class="weui-msg__opr-area">
		    <div class="weui-btn-area">
		      <button class="weui-btn weui-btn_primary">登录</button>
			    <div class="weui-flex">
			    	#if(param("AUTH_MEMBER_REGISTER_ONOFF")=="ON")
				  	<div class="weui-flex__item" style="text-align: left;">
				  		<a style="color:#FFF" href="#(res_path)#(PRE_PATH)/auth/register?redirect=#(redirect)">注册会员</a>
				  	</div>
				  	#end
			    	#if(param("AUTH_MEMBER_FORGET_ONOFF")=="ON")
				  	<div class="weui-flex__item" style="text-align: right;">
				  		<a style="color:#CCC" href="#(res_path)#(PRE_PATH)/auth/forget?redirect=#(redirect)">找回密码</a>
				  	</div>
				  	#end
					</div>
		    </div>
		  </div>
		  #if(param("AUTH_MEMBER_THIRD_ONOFF")=="ON")
		  <p style="color:#CCC;font-size: 12px">其它登录方式</p>
		  <div>
		  	#if(param("AUTH_MEMBER_THIRD_WEIXIN_ONOFF")=="ON")
		  	<a href="#(path)#(PRE_PATH)/auth/weixin/login?redirect=#(redirect)"><i class="iconfont icon-weixin" style="font-size:40px;color:#7ABC11"></i></a>
		  	#end
		  </div>
		  #end
		  <div class="weui-msg__extra-area">
		      <p class="weui-footer__text">Copyright © 2017 #(param("AUTH_MEMBER_NAME"))</p>
		    </div>
		  </div>
		</div>
	</form>
</div>
#end
#define jsFunction()
<script>

	$(".weui-vcode-img").click(function () {
		$(this).attr("src", "captcha?r=" + Math.random());
	});
	function ajaxSubmit(obj){
		var username = $(obj).find("input[name='username']").val();
		var password = $(obj).find("input[name='password']").val();
		if(username==""){
			layer.alert("请输入用户名/手机号/邮箱",{icon:2});
			return false;
		}
		if(password==""){
			layer.alert("请输入密码",{icon:2});
			return false;
		}
		$.ajax({
			type:"POST",
			url:"#(res_path)#(PRE_PATH)/auth/doLogin",
			data:$(obj).serialize(),
			async:false,
			dataType:"json",
			success:function(data){
				if(data.result=="success"){
					location.href="#(redirect??"index")";
				}else {
					if(data.errcode==2){
						$(".weui-cell_vcode").show();
						$(".weui-vcode-img").trigger("click");
					}
					layer.alert(data.message,{icon:2});
				}
			}
		});
		return false;
	}
</script>
#end